home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
lists
/
mint
/
l_0399
/
68
< prev
next >
Wrap
Internet Message Format
|
1994-08-27
|
2KB
From: Julian F. Reschke <julian@GINA.UNI-MUENSTER.DE>
Subject: New Fcntl's
Date: Thu, 28 Jan 93 19:56:42 MET DST
Proposal for new Fcntl opcodes (1st attempt)
--------------------------------------------
#define FUTIME (('F'<< 8) | 3)
#define FTRUNCATE (('F'<< 8) | 4)
These new Fcntl calls can be implemented by loadable (or builtin) file
systems.
Descriptions (party copied from POSIX.1 and SunOS manual pages):
------------
struct mutimbuf {
ULONG actime; /* GEMDOS format */
ULONG modtime;
};
LONG Fcntl (WORD fh, struct mutimbuf *times, FUTIME);
Sets the access and modification times of the named file.
The times argument is interpreted as a pointer to a mutimbuf structure,
and the access and modification times are set to the values contained
in the designated structure.
Returns: 0 (OK), EINVAL (opcode not available) or another error code.
LONG Fcntl (WORD fh, LONG length, FTRUNCATE);
This Fcntl opcode causes the file referred to by fh to have a size equal
to length bytes. If the file was previously longer than length, the
extra bytes are removed from the file. If it was shorter, bytes between
the old and new lengths are read as zeroes. The file must be open for
writing.
Returns: 0 (OK), EINVAL (opcode not available) or another error code.
Example
-------
UNTESTED utime() implementation (source copied from MiNT-Lib PL26):
int
utime(_filename, tset)
const char *_filename;
const struct utimbuf *tset;
{
int fh;
time_t settime;
struct mutimbuf mt;
char filename[PATH_MAX];
long r;
if (tset) {
mt.actime = dostime (tset->actime);
mt.modtime = dostime (tset->modtime);
}
else {
time (&settime);
mt.actime = mt.modtime = settime;
}
(void)_unx2dos(_filename, filename);
fh = (int) Fopen(filename, 2);
if (fh < 0) {
errno = -fh;
return -1;
}
r = Fcntl (fh, &mt, FUTIME);
if (r == EINVAL)
r = Fdatime ((_DOSTIME *) &mt.modtime, fh, 1);
if ((fh = Fclose(fh)) != 0) {
errno = -fh;
return -1;
}
return 0;
}
--
________________ cut here _________________________
Julian F. Reschke, Hensenstr. 142, D-W4400 Muenster
eMail: julian@math.uni-muenster.de, jr@ms.maus.de
________ correct me if I'm wrong __________________